package cn.cn.tedu.file;

import java.io.*;

/**
 * @author ：Dsi
 * @date ：2021/11/16 10:13
 * Describe ：该类用于练习字节输入流
 */
public class TestIn {
    public static void main(String[] args) throws Throwable {
    method1();//普通输入流
    //method2();//高效输入流
    }
    private static void method2() throws Throwable {
        //InputStream in1=new FileInputStream("D:\\ready\\1.txt");//多态创建
        FileInputStream in2 = new FileInputStream("D:\\ready\\1.txt");//纯纯子类创建
        int a;
        while((a=in2.read()) != -1){
            System.out.println(a);
        }
        in2.close();
    }
    private static void method1() {
        BufferedInputStream b=null;
        try {
            b = new BufferedInputStream(new FileInputStream("D:\\ready\\1.txt"));
            int a;
            while((a=b.read()) != -1){
                System.out.println(a);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                b.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
